<script setup lang="ts">
import { useHomeStore } from "@/stores/homeStore";
import { navigationStore } from "@/stores/navigationStore";
//获取用导航store对象
const navStore = navigationStore();
navStore.get_Navlist({
  nid: 18,
  title: "博客",
  order_by: "create_date",
});
const { navList } = storeToRefs(navStore);
//获取首页的store实例
const homeStore = useHomeStore();
//获取收藏列表
homeStore.getpopularActive();
//获取最新修改
homeStore.getchange_dateActive();
</script>
<template>
  <div class="left">
    <div class="nianxing">
      <div class="popular">
        <div class="title"><div class="lvbiao">更多推荐</div></div>

        <ul>
          <div
            class="loading"
            v-if="homeStore.popularActive.status == 'loading'"
          >
            <span class="img"></span>
            <span class="text">正在加载...</span>
          </div>
          <li v-else v-for="active in homeStore.popularActive.result">
            <div class="left">
              <img :src="active.cover" alt="" />
            </div>
            <div class="right">
              <p>{{ active.title }}</p>
              <span>{{ active.collects_count }} collects </span>
            </div>
          </li>
        </ul>
      </div>
      <div class="about popular">
        <div class="title"><div class="lvbiao">友情链接</div></div>
        <ul>
          <a target="_blank" v-for="item in navList.result" :href="item.href"
            ><li>
              <i class="fa fa-spinner" aria-hidden="true"></i>{{ item.title }}
            </li></a
          >
        </ul>
      </div>
    </div>
  </div>
</template>
<style scoped lang="scss">
.left {
  width: 15%;
  margin-left: 3%;

  .nianxing {
    position: sticky;
    top: 10%;
    .popular {
      .title {
        .lvbiao {
          padding-left: 5px;
          border-left: 3px solid #08d9d6;
          color: #000;
          font-weight: bold;
        }
      }
      ul {
        margin-left: 15px;
        margin-right: 15px;
        padding-top: 15px;

        padding-bottom: 20px;
        border-top: 1px solid var(--el-border-color);
        li:hover img {
          transform: scale(1.1);
        }
        li {
          margin-top: 10px;
          display: flex;
          cursor: pointer;
          overflow: hidden;

          .left {
            img {
              width: 50px;
              height: 50px;
              border-radius: 10px;
              transition: all 0.3s;
            }
          }
          .right {
            margin-left: 35px;
            p {
              font-size: 12px;
              color: var(--el-text-color-secondary);
              margin-top: 5px;
              margin-bottom: 10px;
            }
            span {
              font-size: 12px;
              color: var(--el-border-color-darker);
            }
          }
        }
      }
    }
    .about {
      ul {
        margin-left: 15px;
        margin-right: 15px;
        padding-top: 15px;
        padding-bottom: 20px;
        border-top: 1px solid var(--el-border-color);
        li:hover {
          box-shadow: 1px 1px 15px var(--el-color-info-light-3);
        }
        li {
          margin-top: 10px;
          height: 30px;
          line-height: 30px;
          background-color: var(--el-color-info-light-8);
          border-radius: 10px;
          font-size: 10px;
          color: var(--el-color-info);
          transition: all 0.3s;
          i {
            margin-left: 10px;
            margin-right: 5px;
            line-height: 30px;
          }
        }
      }
    }
    .loading {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 200px;
      .img {
        width: 200px;
        height: 200px;
        background: url(@/assets/img/login.gif) no-repeat center / contain;
      }
      .text {
        display: block;
        color: #999;
        font-size: 16px;
      }
    }
  }
}
</style>
